package topcoder;

import java.util.*;

public class TheNumberGameDivTwo {

	Map<Integer, List<Integer>> divisors(int n) {
		HashMap<Integer, List<Integer>> D = new HashMap<Integer, List<Integer>>();
		
		for(int i = 0; i <= n; i++)
			D.put(i, new ArrayList<Integer>());
		
		for (int i = 2; i <= n/2; i++) {
			int j = 2;
			int d = i * j;
			while (d <= n) {
				D.get(d).add(i);
				
				j++;
				d = i * j;
			}
		}
		
		return D;
	}
	
	boolean _find2(int n, Map<Integer, List<Integer>> D) {
		boolean[] win = new boolean[n+1];
		for (int i = 0; i <= n; i++) {
			for (int d : D.get(i)) {
				if (!win[i-d]) {
					win[i] = true;
					break;
				}
			}
		}
		return win[n];
	}
	
	boolean _find(int n, int i, Map<Integer, List<Integer>> D) {
		if (i % 2 == 0) {
			for (int d : D.get(n)) {
				if ( _find(n - d, i + 1, D) )
						return true;
			}
			return false;
		} else {
			for (int d : D.get(n)) {
				if ( !_find(n - d, i + 1, D) )
					return false;
			}
			return true;
		}
	}
	
	public String find(int n) {
		if ( _find2(n, divisors(n)) )
			return "John";
		else
			return "Brus";
	}
	
	public static void main(String[] args) {
		TheNumberGameDivTwo r = new TheNumberGameDivTwo();
		System.out.println(r.find(231));
	}
}
